/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package TimeRecording.enums;

/**
 *
 * @author david
 */
public enum PartOfDay  {
    
    ALL_DAY("Full Day"),
    AM("A.M."),
    PM("P.M.");

    private String description;

    private PartOfDay(String description) {
        this.description = description;
    }

    @Override
    public String toString() {
        return description;
    }

    public static PartOfDay fromString(String match) {
        for (PartOfDay candidate : values()) {
            if (candidate.description.equals(match)) {
                return candidate;
            }
        }
        return valueOf(match);
    }

    public static PartOfDay add(PartOfDay part1, PartOfDay part2) {

        if (part1 == null) {
            return part2;
        }
        if (part2 == null) {
            return part1;
        }
        if (part1 == part2) {
            return part1;
        }

        // To get this far, both parts must be specified and different.
        // The only logical conclusion is that we have a full day
        return PartOfDay.ALL_DAY;
    }
}
